pub use crate::models::AppConfig;
use config::{Config, Environment, File};
use std::result::Result;

pub fn load_config() -> Result<AppConfig, config::ConfigError> {
    let config_ = Config::builder()
        .add_source(File::with_name("config.toml"))
        .add_source(Environment::with_prefix("TODO").separator("_"))
        .build()
        .expect("构建配置错误");

    let config: AppConfig = config_.try_deserialize()?;
    Ok(config)
}
